<template>
  <div class=''>
    <div id="myChart" :style="{width: '100%', height: '300px'}"></div>
  </div>
</template>
<script>
import echarts from 'echarts'
export default {
  data () {
    return {
    }
  },
   mounted(){
    this.drawLine();
  },
  methods: {
    drawLine(){
      // 引入 ECharts 主模块
      var echarts = require('echarts/lib/echarts'); // 重点 一定要这样引入，不然引入会报错，webpack引入
      // 引入柱状图
      require('echarts/lib/chart/bar');
      require('echarts/lib/chart/line');
      // 引入提示框和标题组件
      require('echarts/lib/component/tooltip');
      require('echarts/lib/component/title');
      // 基于准备好的dom，初始化echarts实例
      let myChart = echarts.init(document.getElementById('myChart'))
      // 绘制图表
      myChart.setOption({
          title: { text: '在Vue中使用echarts' },
          tooltip: {},
          xAxis: {
              data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
          },
          yAxis: {},
          series: [
            {
              name: '销量',
              type: 'bar',
              data: [5, 20, 36, 10, 10, 20]
            },
            {
              name: '销量2',
              type: 'line',
              data: [17, 23, 44, 16, 234, 61]
            },
          ]
      });
    }
  }
}
</script>

<style scoped>
</style>
